package com.ala4.oxcafe.entity;

import com.ala4.oxcafe.core.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 用户信息
 *
 * @author PING
 * @version 1.0.0
 * @date 2025/8/12 12:39
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("user_info")
@Schema(description = "用户信息")
public class UserInfo extends BaseEntity {

    @Schema(description = "主键id")
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @NotNull(message = "ID不能为空", groups = {Update.class})
    private Long id;

    @Schema(description = "部门ID")
//    @NotNull(message = "部门不能为空", groups = {Create.class, Update.class})
    private Long deptId;

    @Schema(description = "用户账号")
    @NotNull(message = "用户账号不能为空", groups = {Create.class})
    @NotEmpty(message = "用户账号不能为空", groups = {Create.class})
    private String userAccount;

    @Schema(description = "用户昵称")
    @NotNull(message = "用户昵称不能为空", groups = {Create.class, Update.class})
    @NotEmpty(message = "用户昵称不能为空", groups = {Create.class, Update.class})
    private String nickName;

    @Schema(description = "手机号码")
    @NotNull(message = "手机号码不能为空", groups = {Create.class, Update.class})
    @NotEmpty(message = "手机号码不能为空", groups = {Create.class, Update.class})
    private String phoneNumber;

    @Schema(description = "用户密码")
    @NotNull(message = "用户密码为空", groups = {Create.class})
    @NotEmpty(message = "用户密码为空", groups = {Create.class})
    private String password;

    @Schema(description = "帐号状态（0正常 1停用）")
    @NotNull(message = "帐号状态为空", groups = {Create.class, Update.class})
    private Integer status;

    @Schema(description = "是否门店用户(0是 1否)")
    private Integer isStoreUser = 1;

    @Schema(description = "门店ID-如果有门店ID就会带门店ID查询业务数据")
    private Long storeId;

    @Schema(description = "邮箱")
    private String email;

    @Schema(description = "用户性别（0男 1女 2未知）")
    private Integer sex;

    @Schema(description = "头像地址")
    private String avatar;

    @Schema(description = "最后登录IP")
    private String loginIp;

    @Schema(description = "最后登录时间")
    private LocalDateTime loginDate;

    @Schema(description = "用户角色ID")
    @TableField(exist = false)
    private List<Long> roleIds;

    @Schema(description = "用户角色信息")
    @TableField(exist = false)
    private List<String> roleCodes;

    public interface Create {
    }

    public interface Update {
    }

}
